/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/cat.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __JSP_JSP_FUNCTIONS_H__
#define __JSP_JSP_FUNCTIONS_H__

#include "../impl/head.h"

namespace xos_jsp
{

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // 

    // 
    // 超级变量取值
    // 
    int supper_variable_to_html( http::i_task * pTask, const char * lpszVariable );

    // 
    // 标签间内容
    // 
    int html_to_html( http::i_task * pTask, const std::string & str );

    // 
    // 将各种类型的数据，转成字串输出
    // 
    template< class T >
    inline int variable_to_html( http::i_task * pTask, T v )
    {
        int ret = 0;

        xos_box::i_variant * pVT = 0;
        {
            xos_box::i_list * pList = pTask->http_response()->body_list();
            const char * pStr = 0;
            pVT = mgr::container()->box()->vt();
            pVT->set( v );
            pStr = pVT->str();
            pList->add_str( pStr, true );
        }
        xos_stl::release_interface( pVT );

        return ret;
    }

} // xos_jsp

#endif // __JSP_JSP_FUNCTIONS_H__
